IF exists(SELECT * FROM dbo.sysobjects WHERE name='WEB_menu' AND xtype='P') 
BEGIN
	DROP PROCEDURE WEB_menu
END
GO

CREATE        procedure WEB_menu(
@iNr varchar(7),
@logon varchar(50))
as
set nocount on

declare @seminaries int
declare @cellid bit
declare @directielid bit
declare @afwezigheden bit
declare @agendabeheerder bit
declare @werkplan bit
declare @klas varchar(5)

select @klas = klas 
	from leerlingen..leerlingen as s
where inschrijvingsNr = @iNr

select @seminaries = count(s.groepscode) 
	from leerlingen..seminarieGroepen as s
where inschrijvingsNr = @iNr

if exists(select * from studiebegeleiding..sec_cellid
	where logon = @logon) set @cellid = 1
	else set @cellid = 0

if exists(select * from studiebegeleiding..sec_directielid
	where logon = @logon) set @directielid = 1
	else set @directielid = 0

if exists(select * from studiebegeleiding..sec_afwezigheden
	where logon = @logon) set @afwezigheden = 1
	else set @afwezigheden = 0


if exists(select * from studiebegeleiding..sec_agendaBeheer
	where logon = @logon) set @agendaBeheerder = 1
	else set @agendaBeheerder = 0

if exists(select * from studiebegeleiding..sec_werkplan
	where logon = @logon) set @werkplan = 1
	else set @werkplan = 0

select @seminaries as seminariegroep, @cellid as cellid, 
@directielid as directie, @afwezigheden as afwezigheden, 
@agendaBeheerder as agendabeheerder,@werkplan as werkplan, 
isNull(@klas,'klas') as klas